Cryptography. The science of developing secret codes has interested many people for centuries. Some of the simplest codes involve replacing a...

profilejoremt

 Prgogram for C

 

Cryptography. The science of developing secret codes has interested many people for centuries. 

Some of the simplest codes involve replacing a character, or a group of characters, with another 

character, or group of characters. To easily decode these messages, the decoder needs the “key” 

that shows the replacement characters. For your second project you will write two programs that 

do the following: 

 

1. Write a program to implement a simple code that replaces each character by another character 

that is a fixed number of positions away in the collating sequence. For example, if each character 

is replaced by the character that is two characters to the right, then the letter ‘a’ is replaced by the 

letter ‘c’, the letter ‘b’ is replaced by the letter ‘d’, and so on. Your program should be able to 

read a text in a file (create your own, name it “message.txt”), and then generate a new file that 

contains the coded text using this encryption technique (name it “encryptMessage.txt”). Do not 

change the newline characters or the EOF character. 

Your program should allow the user to choose the “key” for encryption, i.e. if the user enters 4 

then each character is replaced by a character that is 4 characters to the right or if the user enters 

-4 then each character is replaced by 4 characters to the left. Use an ASCII character chart to 

make sure that you are replacing the characters properly. 

Your program should also create a file called “key.txt” that contains the key used to encrypt the 

message. 

2. Write a program that will decode the encryption scheme in problem 1. Test your program 

using the files generated in 1. 

 

What to turn in: For this project you will only need to turn in the code (just like you have done 

for home works and project 1) and the text files used/generated for part 1. Your *.c file must be 

well documented, i.e. you must include comments throughout the program. The code must 

readable i.e. user proper spacing and indentation. I will be testing your programs using the files 

you provide as well as my own message file. 

    • 13 years ago
    • 20
    Answer(3)

    Purchase the answer to view it

    blurred-text
    NOT RATED
    • attachment
      encrypt.png
    • attachment
      encrypt.zip

    Purchase the answer to view it

    blurred-text
    NOT RATED
    • attachment
      encrypt1.docx
    • attachment
      decrypt2.docx

    Purchase the answer to view it

    blurred-text
    NOT RATED
    • attachment
      tmp_crypto1338874003.zip